import { mdiAlert } from '@quasar/extras/mdi-v7';
import { Notify, QNotifyOptions, Dialog, QDialogOptions, QDialogInputPrompt } from 'quasar';

export const DEL_MESSAGE_WARNING = '<div style="color:green;margin-top:15px">数据删除后无法恢复，请慎重操作！</div>';
export const DEL_MESSAGE = `确认要删除选中的数据吗？${DEL_MESSAGE_WARNING}`;

/**
 * 消息组件
 */
export type MessageType = 'success' | 'error' | 'warning' | 'info';
export const Message = {
  success: (message: string, options: QNotifyOptions = {}) => Notify.create({ type: 'positive', message, ...options }),
  error: (message: string, options: QNotifyOptions = {}) => Notify.create({ type: 'negative', message, ...options }),
  warning: (message: string, options: QNotifyOptions = {}) => Notify.create({ type: 'warning', message, icon: mdiAlert, ...options }),
  info: (message: string, options: QNotifyOptions = {}) => Notify.create({ type: 'info', message, ...options }),
};
/**
 * 消息提示窗口
 */
export const MessageBox = {
  alert: (message: string, title = '警告', options: QDialogOptions = {}) =>
    Dialog.create({ title, message, cancel: true, html: true, ...options }),

  confirm: (message: string, title = '请确认', options: QDialogOptions = {}) =>
    Dialog.create({
      title,
      message,
      cancel: true,
      persistent: true,
      ok: { color: 'primary', dense: true },
      html: true,
      ...options,
    }),

  prompt: (message: string, prompt: QDialogInputPrompt = { model: '' }, title = '输入...', options: QDialogOptions = {}) =>
    Dialog.create({
      title,
      message,
      prompt: { type: 'text', outlined: true, dense: false, ...prompt },
      cancel: true,

      persistent: true,
      ...options,
    }),
};
